<%-- 
    Document   : ViewProduct
    Created on : Mar 29, 2012, 4:57:53 AM
    Author     : Tokino
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.CallableStatement"%>
<%@page import="dbhandler.DBConnector"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1" />
        <META Http-Equiv="Cache-Control" Content="no-cache"/>
        <META Http-Equiv="Cache-Control" Content="no-store"/>
        <META Http-Equiv="Pragma" Content="no-cache"/>
        <META Http-Equiv="Expires" Content="0"/>

        <%
            response.setHeader("Cache-Control", "no-cache, must-revalidate, no-store");
            response.setHeader("Pragma", "no-cache");
            response.setDateHeader("Expires", 0);

        %>

        <link rel="stylesheet" href="../css/style.css" type="text/css" id="" media="print, projection, screen" />
        <script type="text/javascript" src="../script/jquery-latest.js"></script>
        <script type="text/javascript" src="../script/jquery.tablesorter.js"></script>
        <script type="text/javascript" src="../script/jquery.tablesorter.pager.js"></script>

        <script type="text/javascript">
            $(document).ready(function() {
                // call the tablesorter plugin
                $("table").tablesorter({
                    // sort on the first column and third column, order asc
                    sortList: [[1,0]],
                    headers: {

                    }
                    ,
                    widthFixed: true, widgets: ['zebra']
                })
                .tablesorterPager({container: $("#pager")});
                ;
            });


        </script>
    </head>
    <link rel="stylesheet" href="../style/style.css" type="text/css" id="" media="print, projection, screen" />
    <jsp:useBean id="SecprogScopeSession" class=
                 "servlets.SecprogScopeSession" scope="session" />
    <%
        if (SecprogScopeSession.getAccounttype() == 1) {
            response.sendRedirect("../customer/CMain.jsp");
        } else if (SecprogScopeSession.getAccounttype() == 2) {
            response.sendRedirect("../accounting/PCMain.jsp");
        } else if (SecprogScopeSession.getAccounttype() == 10) {
            response.sendRedirect("../admin/AMain.jsp");
        }
        if (!SecprogScopeSession.getIsLogin()) {
            response.sendRedirect("../index.jsp");
        }

    %>
    <body bgcolor="#FFFACD">

        <table width="94%" border="0" align="center">

            <tr >
                <td style="background-color:#FFA500; height:100px">

                </td>
            </tr>
            <tr style="background-color:#FFA500; height:30px" align="center">

                <td><a href="PMain.jsp">Home</a><font color="#FFFFFF" face="Arial">|</font>
                    <a href="ViewProduct.jsp">Product</a><font color="#FFFFFF" face="Arial">|</font>
                    <a href=""></a><font color="#FFFFFF" face="Arial">|</font>
                    <a href="PSettings.jsp">Settings</a><font color="#FFFFFF" face="Arial">|</font>
                    <a href="../logout/LogoutProcess.jsp">Logout</a>
                </td>

            </tr>

            <tr style="background-color:#FFA500; height:30px" align="center">

                <td><a href="AddProduct.jsp">Add Product</a><font color="#FFFFFF" face="Arial">|</font>
                    <a href="ViewProduct.jsp">View Product</a><font color="#FFFFFF" face="Arial">|</font>
                     <a href="EditProduct.jsp">Edit Product</a><font color="#FFFFFF" face="Arial">|</font>
                    <a href="DeleteProduct.jsp">Delete Product</a>

                </td>

            </tr>


            <tr style="background-color:#FFA500; height:30px" align="center">

                <td><a50>Welcome Manager <%= SecprogScopeSession.getFullName()%><font color="#FFFFFF" face="Arial">|</font>
                Manager since <%= SecprogScopeSession.getDatecreated()%><font color="#FFFFFF" face="Arial">|</font>
                Last Login is <%= SecprogScopeSession.getLastlogin()%></a50>
        </td>

    </tr>

    <tr>
        <td style="padding-top:5%; padding-left:2%; padding-right:2%; padding-bottom:5%; background-color:#EEEEEE;height:auto;width:920px;">
    <a1>View Product</a1><br>


    <table  border="0" id="myTable" class="tablesorter" style="width: 100%;" align="center">
        <thead> 
            <tr> 
                <th>Num</th> 
                <th>Title</th> 

                <th>                <%
                    if (SecprogScopeSession.getAccounttype() == 3) {
                        out.print("Author");
                    }
                    if (SecprogScopeSession.getAccounttype() == 4) {
                        out.print("Publisher");
                    }
                    if (SecprogScopeSession.getAccounttype() == 5) {
                        out.print("Artist");
                    }
                    if (SecprogScopeSession.getAccounttype() == 6) {
                        out.print("Year");
                    }

                    %></th> 
                <th>Category</th> 
                <th>Type</th> 
                <th>Synopsis</th> 
                <th>Price</th> 
                <th>Date Added</th>  
                <th>Date Modified</th> 
            </tr> 
        </thead>                 
        <tfoot> 
            <tr> 
                <th>Num</th> 
                <th>Title</th> 
                <th><%
                    if (SecprogScopeSession.getAccounttype() == 3) {
                        out.print("Author");
                    }
                    if (SecprogScopeSession.getAccounttype() == 4) {
                        out.print("Publisher");
                    }
                    if (SecprogScopeSession.getAccounttype() == 5) {
                        out.print("Artist");
                    }
                    if (SecprogScopeSession.getAccounttype() == 6) {
                        out.print("Year");
                    }

                    %></th> 
                <th>Category</th> 
                <th>Type</th> 
                <th>Synopsis</th> 
                <th>Price</th> 
                <th>Date Added</th>  
                <th>Date Modified</th> 
            </tr> 
        </tfoot> 

        <tbody> 
            <%
                //colid, username, fname, lname, mi, email, accounttype, datecreated, lastlogin, lastmodified, status 
                DBConnector dbConnectorchk = null;
                dbConnectorchk = new DBConnector("localhost", 3306, "selector", "53l3ct0r", "bookaholic");
                dbConnectorchk.connectToDB();
                CallableStatement callable = null;
                ResultSet result = null;
                String authCall = "{ call view_products() }";
                callable = dbConnectorchk.getConnection().prepareCall(authCall);
                result = callable.executeQuery();

                if (SecprogScopeSession.getAccounttype() == 3) {
                    SecprogScopeSession.setViewProductDelimiter("Book");
                }
                if (SecprogScopeSession.getAccounttype() == 4) {
                    SecprogScopeSession.setViewProductDelimiter("Magazine");

                }
                if (SecprogScopeSession.getAccounttype() == 5) {
                    SecprogScopeSession.setViewProductDelimiter("Audio CD");

                }
                if (SecprogScopeSession.getAccounttype() == 6) {
                    SecprogScopeSession.setViewProductDelimiter("Movie");

                }


                while (result.next()) {

if(result.getString("category").equals(SecprogScopeSession.getViewProductDelimiter())){
            %>

            <tr> 
                <td><%=result.getInt("colid")%></td>
                <td><%=result.getString("title")%></td>
                <td><%=result.getString("addinfo")%></td>
                <td><%=result.getString("category")%></td>
                <td><%=result.getString("type")%></td>
                <td><%=result.getString("synopsis")%></td>
                <td><%=result.getString("price")%></td>
                <td><%=result.getString("dateadded")%></td>
                <td><%=result.getString("datemodified")%></td>
                <%          }      }
                    dbConnectorchk.disconnectDB();
                %>


        </tbody> 
    </table> 
    <div id="pager" class="pager" align="left" style=" height: auto; width: 95%;">
        <form>
            <img src="addons/pager/icons/first.png" class="first"/>
            <img src="addons/pager/icons/prev.png" class="prev"/>
            <input readonly="readonly" type="text" class="pagedisplay"/>
            <img src="addons/pager/icons/next.png" class="next"/>
            <img src="addons/pager/icons/last.png" class="last"/>
            <select class="pagesize">
                <option selected="selected"  value="10">10</option>

                <option value="20">20</option>
                <option value="30">30</option>
                <option  value="40">40</option>
            </select>
        </form>
    </div>
    <br>
    <br>


    username is <%= SecprogScopeSession.getUserName()%>
    Session  is <%= SecprogScopeSession.getIsLogin()%>
    accounttype  is <%= SecprogScopeSession.getAccounttype()%>
    Session  is <%= SecprogScopeSession.getSessionid()%>

    </td>
    </tr>

    <tr>
        <td colspan="2" style="background-color:#FFA500;text-align:center;">
            Copyright © 2011</td>
    </tr>
</table>

</body>
</html> 